﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using Loki.Utils;

namespace Loki.Engine
{
    public class EntityStore<TEntityClass, TEntityKey> : LokiObject, IDisposable, IContainer<TEntityClass>, IIndexedEnumerable<TEntityClass, TEntityKey>
         where TEntityClass : IAtomicEntity<TEntityKey>
    {
        public EntityStore(ContainerConfiguration<TEntityClass, TEntityKey> P_Config)
        {

        }

        public void FullLoad()
        {
            throw new NotImplementedException();
        }

        public void Reset()
        {
            throw new NotImplementedException();
        }

        public bool Register(TEntityClass P_Entity)
        {
            throw new NotImplementedException();
        }

        public void Remove(TEntityClass P_Entity)
        {
            throw new NotImplementedException();
        }

        public IEnumerator<TEntityClass> GetEnumerator()
        {
            throw new NotImplementedException();
        }

        IEnumerator IEnumerable.GetEnumerator()
        {
            throw new NotImplementedException();
        }
        #region CollectionChanged
        private readonly object CollectionChangedEventLock = new object();
        private NotifyCollectionChangedEventHandler CollectionChangedEvent;

        public event NotifyCollectionChangedEventHandler CollectionChanged
        {
            add
            {
                lock (CollectionChangedEventLock)
                {
                    CollectionChangedEvent += value;
                }
            }
            remove
            {
                lock (CollectionChangedEventLock)
                {
                    CollectionChangedEvent -= value;
                }
            }
        }

        protected virtual void OnCollectionChanged(NotifyCollectionChangedEventArgs e)
        {
            NotifyCollectionChangedEventHandler handler = null;

            lock (CollectionChangedEventLock)
            {
                handler = CollectionChangedEvent;

                if (handler == null)
                    return;
            }

            handler(this, e);
        }

        #endregion

        public TEntityClass this[TEntityKey P_Index]
        {
            get { throw new NotImplementedException(); }
        }

        public IEnumerable<TEntityClass> this[string P_IndexName, object P_IndexValue]
        {
            get { throw new NotImplementedException(); }
        }

        public void Dispose()
        {
            throw new NotImplementedException();
        }
    }
}
